package cn.mes.module.mes.dal.mysql.baseworkshop;

import java.util.*;

import cn.mes.framework.common.pojo.PageResult;
import cn.mes.framework.common.pojo.PageParam;
import cn.mes.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.mes.framework.mybatis.core.mapper.BaseMapperX;
import cn.mes.module.mes.controller.admin.baseworkshop.vo.MachineAreaListReqVO;
import cn.mes.module.mes.controller.admin.baseworkshop.vo.WorkShopListReqVO;
import cn.mes.module.mes.dal.dataobject.baseworkshop.BaseMachineAreaDO;
import cn.mes.module.mes.dal.dataobject.baseworkshop.BaseWorkShopDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 生产区域信息 Mapper
 *
 * @author 游创
 */
@Mapper
public interface BaseMachineAreaMapper extends BaseMapperX<BaseMachineAreaDO> {

    default PageResult<BaseMachineAreaDO> selectPage(PageParam reqVO, String workShopId) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BaseMachineAreaDO>()
            .eq(BaseMachineAreaDO::getWorkShopId, workShopId)
            .orderByAsc(BaseMachineAreaDO::getOrderNo));
    }


    default List<BaseMachineAreaDO> selectList(MachineAreaListReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<BaseMachineAreaDO>()
                .likeIfPresent(BaseMachineAreaDO::getMachineArea, reqVO.getName())
                .eqIfPresent(BaseMachineAreaDO::getStatus, reqVO.getStatus()));
    }

    default int deleteByWorkShopId(String workShopId) {
        return delete(BaseMachineAreaDO::getWorkShopId, workShopId);
    }

}
